const router = require('koa-router')()
const { addUser, modifyUser, getUserList, getUserById, modifyById, deleteUser,ModifyUserRole,getUserByName } = require("../controller/user_controller")
const { handlePassword, verifyUser } = require("../middleware/user_middleware")
const {verifyAuth}=require("../middleware/auth_middleware")
router.prefix('/users')

router.post("/register", verifyUser, handlePassword, addUser)
router.post("/", verifyAuth, modifyUser)
//后台管理
router.get("/",verifyAuth,getUserList)
router.get("/:id",verifyAuth,getUserById)
router.put("/:id", verifyAuth, modifyById)
router.delete("/:id", verifyAuth, deleteUser)
//修改用户权限
router.put("/role/:id", verifyAuth, ModifyUserRole)
//搜索用户
router.post("/search",verifyAuth,getUserByName)
module.exports = router
